<!DOCTYPE html>
<html>
  <head>
    <title>监控服务</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        margin: 20px;
      }
      .status {
        padding: 10px;
        margin: 10px 0;
        border-radius: 5px;
      }
      .running {
        background-color: #dff0d8;
      }
      .stopped {
        background-color: #f2dede;
      }
    </style>
  </head>
  <body>
    <h1>监控服务状态页面</h1>
    <div class="status running" id="status">服务状态: 运行中</div>
    <div>
      <h2>最新消息</h2>
      <ul id="messages"></ul>
    </div>
    <script>
      // 定时请求后端，进行获取最新消息
      setInterval(() => {
        fetch('/api/logs')
          .then((response) => response.json())
          .then((data) => {
            const messages = document.getElementById('messages');
            messages.innerHTML = '';
            data.forEach((log) => {
              const li = document.createElement('li');
              li.textContent = log.message;
              messages.appendChild(li);
            });
          });
      }, 5000);
    </script>
  </body>
</html>
